// Implementation of A* Node
// Nick Kitten

#include "Node.h"
#include <limits>
using namespace std;

Node::Node()
{
	int inf = numeric_limits<int>::max();
	g = inf;
	h = inf;
	f = inf;
	position.x = 0;
	position.y = 0;
	this->parent = NULL;
}

Node::Node( Position pos, int _g, int _h, Node * par ) 
: position(pos), g(_g),h(_h),parent(par),f(_g+_h)
{
}

Node::Node( const Node & n )
{
	*this = Node( n.getPosition(), n.G(), n.H(), n.Parent() );
}

Node::~Node()
{
}

int Node::F() const
{
	return this->f;
}

int Node::G() const
{
	return this->g;
}

int Node::H() const
{
	return this->h;
}

void Node::G(int g)
{
	this->g = g;
	this->f = g + h;
}

void Node::H(int h)
{
	this->h = h;
	this->f = g + h;
}

Node * Node::Parent() const
{
	return this->parent;
}

void Node::Parent(Node *par)
{
	this->parent = par;
}

Position Node::getPosition() const
{
	return position;
}

void Node::setPosition( Position pos )
{
	position = pos;
}

bool Node::operator>( const Node & rh ) const
{
	return this->f > rh.f;
}

bool Node::operator<( const Node & rh ) const
{
	return this->f < rh.f;
}
